package array;
//移动0
public class leetcode283 {
    public static void main(String[] args) {
        int[] nums = {0,1,0,3,12};
        moveZeros(nums);
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i] + " ");
        }
    }

    public static void moveZeros(int[] nums){
        if(nums.length <= 1) return;
        int fast = 1;
        int slow = 0;
        while(fast <= nums.length - 1){
            if(nums[slow] == 0 && nums[fast] != 0){
                int temp = nums[fast];
                nums[fast] = nums[slow];
                nums[slow] = temp;
                slow++;
                fast++;
            }
            else if(nums[slow]==0 && nums[fast] == 0){
                fast++;
            }
            else{
                slow++;
                fast++;
            }
        }
    }
}
